﻿-- Procedure Header --
/******************************************
 * Procedure attempts to add new drink type
 * Darren Comeau
 * 19/01/2011
 *****************************************/
-- Procedure Header --

CREATE PROCEDURE [dbo].[addDrinkType]
	@DrinkType NVARCHAR(101) -- 1 larger than column to detect truncation issues
AS
BEGIN
SET NOCOUNT ON
BEGIN TRANSACTION	
	BEGIN TRY
		INSERT INTO dbo.DrinkType(DrinkType) VALUES(@DrinkType)
		COMMIT TRANSACTION
	END TRY
	BEGIN CATCH
		IF ERROR_NUMBER() = 8152
			PRINT 'Failed to insert new drink type, parameter to long.'
		ELSE
			PRINT 'Failed to insert new drink type "' + @DrinkType + '".'
		ROLLBACK TRANSACTION
		RETURN ERROR_NUMBER()
	END CATCH
RETURN 0
END